﻿using Basic.UserModel.DB;
using Basic.UserRemoteModel;
using WeDonekRpc.Helper;
using WeDonekRpc.SqlSugar;

namespace Basic.UserRepository.lmpl
{
    internal class LoginUserRepository : UserBaseRepository<DBLoginUser, long>, ILoginUserRepository
    {
        public LoginUserRepository (ISqlClientFactory factory) : base(factory)
        {
        }

        public long GetUserId (string loginName, LoginType loginType)
        {
            long userId = base.Get(c => c.LoginName == loginName && c.LoginType == loginType, c => c.UserId);
            if (userId == 0)
            {
                throw new ErrorException("user.no.reg");
            }
            return userId;
        }
    }
}
